
class_name UnitSkill
extends Node




## unit 的技能组件
## 技能的添加，使用在此组件实现




## 组件的装载者
@onready var master: Unit = null
@export var skills: Array[NodePath] = []




func _ready() -> void:
	master = get_parent()




func _enter_tree() -> void:
	master = get_parent()




# 技能增加
func add_skill(_skill: Skill) -> void:
	pass




## 技能请求
func skill_request(_skill: Skill) -> void:
	## 在使用技能前先判断是否满足技能释放条件
	if _skill.cost():
		master.hide_action_ui()
		_skill.start({
			"user": master
		})




## 检测被动技能的释放
func auto_skill_check(_args: Dictionary) -> void:
	for skill in skills:
		get_node(skill).auto(_args)




## 回合结束时由 master 调用
func cycle(_round_number: int) -> void: 
	for skill in skills:
		get_node(skill).auto({
			"class": "ROUND_END",
			"user": master,
			"round_number": _round_number
		})
	pass
